<!DOCTYPE html>
<html>
<head>
    <title>会员绑定</title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
    <link href="<%= global.config.path.publicPath %>/custom/officialAccount/css/officalCommon.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll_002.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %>/libs/mobiscroll-master-black/css/mobiscroll_003.css" rel="stylesheet">
    <link href="<%= global.config.path.publicPath %><%= body.stylePath %>" rel="stylesheet">
    <link href="<%=global.config.cdn.path %>/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="stylesheet" href="<%=global.config.cdn.path %>/weui/0.4.3/style/weui.min.css">
    <link rel="stylesheet" href="<%=global.config.cdn.path %>/jquery-weui/0.8.3/css/jquery-weui.min.css">
    <style>
        .content-padded {
            padding: 15px;
        }
        body{
            background-color: #FBF9FE;
        }
        .fa-mobile-phone:before, .fa-mobile:before {
            content: "\f10b";
        }.fa-mobile-phone:before, .fa-mobile:before {
             content: "\f10b";
         }
        .fa-lg {
            font-size: 1.33333333em;
            line-height: .75em;
            vertical-align: -15%;
        }

        button.weui-vcode-btn {
            background-color: transparent;
            border-bottom: 0 none;
            border-right: 0 none;
            border-top: 0 none;
            outline: 0 none;
        }

        .weui-vcode-btn {
            border-left: 1px solid #e5e5e5;
            color: #3cc51f;
            display: inline-block;
            font-size: 17px;
            padding: 0 0.6em 0 0.7em;
        }

        .weui-vcode-btn, .weui-vcode-img {
            margin-left: 5px;
            vertical-align: middle;
        }

        .weui_cells {
            margin-top: 10px;
        }
    </style>

</head>
<body ontouchstart>
<div id="login" class="content-padded">


    <form id="loginForm"  >
        <input type="text" hidden  value="<%=body.brandId%>" name="brandId">
        <input type="text" hidden name="openId">
        <input type="text" hidden  name="publicId">
        <input type="text" hidden name="gId">

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input acc-input" type="text" id="cartNoInput" placeholder="会员卡号" name="cardCode">
                </div>
            </div>
        </div>

        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input acc-input" type="text" id="userNameInput" placeholder="手机号" name="mobile">
                </div>
            </div>
        </div>

        <%
            var showFlag = false;
            if(global.config.introCardCodeGId){
                for(var i = 0; i < global.config.introCardCodeGId.length; i++){
                    if(body.gId === global.config.introCardCodeGId[i]){
                        showFlag = true;
                        break;
                    }
                }
            }
        %>
        <%if(showFlag){%>
        <div class="weui_cells weui_cells_form">
            <div class="weui_cell" style="border: 1px solid #d7d7d7; border-radius:3px;box-shadow: 0 0 0 1px #d7d7d7;">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" id="introCardCode" type="text" placeholder="请输入推荐人卡号" name="introCardCode">
                </div>
            </div>
        </div>
        <%}%>

        <div class="weui_cells weui_cells_form">
            <input type="button" class="weui_btn weui_btn_default" id="submitBtn" value="绑定" onclick="return check(this.form)">
        </div>

        <div style="padding: 1rem 0;" id="goes">
            <a style="color: #333;" class="pull-right" href="javascript:void(0)"><i class="fa fa-mobile-phone fa-lg"></i><span>快速注册</span></a>
            <!--<a style="color: #333;" class="pull-left" th:href="@{/login/forgotPassword}"><i class="fa fa-lock fa-lg"></i><span>找回卡号</span></a>-->
        </div>
    </form>

</div>

<% include common/footer.ejs %>
<script src="<%=global.config.cdn.path %>/jquery/1.11.0/jquery.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/jquery-weui.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/swiper.min.js"></script>
<script src="<%=global.config.cdn.path %>/jquery-weui/0.8.3/js/city-picker.min.js"></script>

<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_002.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_004.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_003.js"></script>
<script type="text/javascript" src="<%=global.config.path.publicPath%>/libs/mobiscroll-master-black/js/mobiscroll_005.js"></script>


<script>

    $('#goes').click(function () {
        window.location.href="<%=global.config.path.contextPath%>/view/register?openid="+contextData.data.openid+"&orgCode="+contextData.data.orgCode+"&publicId=<%=body.publicId%>&gId=<%=body.gId%>&brand="+contextData.data.brand
    })
    $("input[name='openId']").val(contextData.data.openid);
    $("input[name='publicId']").val(contextData.data.publicId);
    $("input[name='gId']").val(contextData.data.gId);
    $("input[name='orgCode']").val(contextData.data.orgCode);

    function check(form) {
        console.log(form);
        if (form.cardCode.value == '') {
            alert("请输入会员卡号!");
            form.cardCode.focus();
            return false;
        }
        if(!(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(form.mobile.value) || (/^(5|6|8|9)\d{7}$/).test(form.mobile.value))){
            alert("请输入正确的手机号码！");
            form.mobile.focus();
            return false;
        }
        $.ajax({
            type: "POST",
            url:'<%=global.config.path.contextPath%>/work/bind',
            data:$('#loginForm').serialize(),
            async: false,
            error: function(request) {
                alert('网络有些差，请退出再试一次吧:)')
            },
            success: function(data) {
                console.log(data);
                if(data.err){
                    alert(data.err);
                }else if(data.resolve){
                    alert(data.resolve)
                }else {
                    window.location.href="<%=global.config.path.contextPath%>/view/index?openId="+contextData.data.openid+"&gId="+contextData.data.gId+"&publicId="+contextData.data.publicId+"&brand="+contextData.data.brand;
                    $('#submitBtn').attr('disabled','disabled')
                }
            }
        })
    }
</script>
</body>
</html>
